package logic

import (
	"context"
	"user_srv/model/redis"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsCodeLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendSmsCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsCodeLogic {
	return &SendSmsCodeLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SendSmsCodeLogic) SendSmsCode(in *user.SendSmsCodeRequest) (*user.SendSmsCodeResponse, error) {
	// todo: 发送短信验证码

	//缓存短信验证码
	redis.RedisSetSmsCode(in.Mobile, in.Code, in.Sale)
	return &user.SendSmsCodeResponse{}, nil
}
